package com.allen.imsystem.chat.mappers;

import com.allen.imsystem.chat.model.dto.ChatCacheDTO;
import com.allen.imsystem.chat.model.vo.ChatSession;
import com.allen.imsystem.chat.model.vo.ChatSessionInfo;
import com.allen.imsystem.chat.model.pojo.PrivateChat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @ClassName PrivateChatMapper
 * @Description 私聊会话数据库表操作
 * @Version 1.0
 */
@Mapper
@Repository
public interface PrivateChatMapper extends BaseMapper<PrivateChat> {

    /**
     * 根据uid查询该用户的私聊会话列表
     * @param uid 用户uid
     */
    List<ChatSession> findChatSessionListByUid(String uid);


    /**
     *
     * @param chatId
     * @param uid
     * @param friendId
     * @return
     */
    ChatSession selectNewMsgPrivateChatData(@Param("chatId") Long chatId,
                                            @Param("uid") String uid, @Param("friendId") String friendId);

    ChatSessionInfo selectPrivateChatData(@Param("chatId") Long chatId, @Param("uid") String uid);

    /**
     * 递增未读消息数
     * @param uid 用户id
     * @param chatId 会话id
     */
    int incrUnreadMsgCount(@Param("uid")String uid, @Param("chatId") Long chatId);
}
